package com.cyx.fruit.service.impl;

import com.cyx.fruit.dao.FruitDAO;
import com.cyx.fruit.dao.impl.FruitDAOImpl;
import com.cyx.fruit.pojo.Fruit;
import com.cyx.fruit.service.FruitService;

import java.util.List;

public class FruitServiceImpl implements FruitService {
    FruitDAO dao;
    @Override
    public List<Fruit> getFruitList(String keyword, Integer pageNumber) {
        return dao.getFruitList(keyword,pageNumber);
    }

    @Override
    public Fruit getFruitByFid(Integer fid) {
        return dao.getFruitByFid(fid);
    }

    @Override
    public void addFruit(Fruit fruit) {
        dao.addFruit(fruit);
    }

    @Override
    public void updateFruit(Fruit fruit) {
        dao.updateFruit(fruit);
    }

    @Override
    public void delFruit(Integer fid) {
        dao.delFruit(fid);
    }

    @Override
    public Integer getPage(String keyword) {
        int fruitCount = dao.getFruitCount(keyword);        //总记录条数
        int pageCount = (fruitCount + 5 -1) / 5;
        return pageCount;
    }
}
